home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-04 / 422mods.zip / JAFO15.422 < prev    next >
Text File  |  1993-04-16  |  8KB  |  264 lines

  1. JAFO15.MOD - The CPS Rate Display Mod
  2. JAFO #1 @8857
  3. Sun Apr 11 1993 20:50:04
  4. ┌────────────────────────────────────────────────────────────────────────────┐
  5. │ Mod Name      : JAFO15.MOD               Mod Author: JAFO 1@1     TerraNET │
  6. │ Difficulty    : ███▒▒▒▒▒▒▒                                1@8857  IceNET   │
  7. │ WWIV Version  : 4.22                                      1@8861  WWIVnet  │
  8. │ Mod Date      : 04/11/93                                  1@18857 WWIVLink │
  9. │ Files Affected: BATCH.C, XFER.C, XFEROVL.C, FCNS.H                         │
  10. │ Description   : The CPS Rate Display Mod                                   │
  11. └────────────────────────────────────────────────────────────────────────────┘
  12.  
  13. ══[ Description ]═════════════════════════════════════════════════════════════
  14.  
  15. This modification gives your BBS the ability to report the cps rates to your
  16. users for all file transfers.
  17.  
  18. Wayne actually added the ability to report cps rates for batch transfers in
  19. WWIV v4.21a, but he only reports them to the sysop log.  He does not display
  20. the cps rates to the user.
  21.  
  22. This mod displays cps rates for regular transfers as well as batch transfers.
  23. Everything is sent to the sysop log as well as the screen.  I actually had
  24. this code written and installed on my BBS about 3-4 months before v4.21a was
  25. released, and as far as I know Wayne did not know I had written it.  Anyway,
  26. I just wanted to clarify that Wayne's code did not give me the idea to do
  27. this mod!
  28.  
  29. ══[ Legend ]══════════════════════════════════════════════════════════════════
  30.  
  31.   =  Existing line - Do not change
  32.   +  Add this line
  33.   -  Remove this line
  34.  
  35. ══[ Step 1 ]══════════════════════════════════════════════════════════════════
  36.  
  37. Please back up your source code.  Even the best programmers make mistakes.
  38.  
  39. ══[ Step 2 ]══════════════════════════════════════════════════════════════════
  40.  
  41. In BATCH.C, make the following changes in "void downloaded".
  42.  
  43. =         if (cps)
  44. =           sprintf(s,get_stringx(1,50),u.filename, cps);
  45. =         else
  46. =           sprintf(s,get_stringx(1,43),u.filename);
  47. =         sysoplog(s);
  48. +         pl(s);
  49. =         if (syscfg.sysconfig & sysconfig_log_dl) {
  50. =           sprintf(s,get_stringx(1,51),
  51. =             nam(&thisuser,usernum), u.filename, date());
  52. =           ssm(u.ownerusr,0,s);
  53. =         }
  54. =       }
  55.  
  56. ══[ Step 3 ]══════════════════════════════════════════════════════════════════
  57.  
  58. In "void uploaded", make the following additions.
  59.  
  60. =               sysoplog(s);
  61. =               outstr(get_string(866));
  62. =               outstr(u.filename);
  63. =               outstr(get_string(867));
  64. -               pl(directories[batch[i1].dir].name);
  65. +               outstr(directories[batch[i1].dir].name);
  66. +               npr(" (%ld cps)\r\n",cps);
  67. =             }
  68. =           }
  69. =           closedl();
  70.  
  71. ══[ Step 4 ]══════════════════════════════════════════════════════════════════
  72.  
  73. In XFER.C, add the following to "void upload".
  74.  
  75. =         farfree(ss);
  76. =       }
  77. =       nl();
  78. =       if (xfer) {
  79. +         _chmod(dszlog,1,0);
  80. +         unlink(dszlog);
  81. =         ti=timer();
  82. =         receive_file(s1,&ok,&u.filetype, u.filename, dn);
  83. =         ti=timer()-ti;
  84.  
  85. ══[ Step 5 ]══════════════════════════════════════════════════════════════════
  86.  
  87. Still in "void upload", make the changes indicated.
  88.  
  89. =             if (check_ul_event(dn,&u)) {
  90. =               if (u.mask & mask_extended)
  91. =                 delete_extended_description(u.filename);
  92. =               ok=0;
  93. =             } else {
  94. =               f=open(s1,O_RDONLY | O_BINARY);
  95. =             }
  96. -           }
  97. +           } else
  98. +             nl();
  99. =         }
  100. =         if (ok) {
  101. =           if (ok==1) {
  102. =             l=filelength(f);
  103. =             u.numbytes=l;
  104.  
  105. ══[ Step 6 ]══════════════════════════════════════════════════════════════════
  106.  
  107. Still in "void upload", do the following changes.
  108.  
  109. =           if (ok==1) {
  110. =             ++status.uptoday;
  111. =             save_status();
  112. +             process_cps(u.filename,directories[dn].name);
  113. -             sprintf(s,get_stringx(1,42),u.filename,directories[dn].name);
  114. -             sysoplog(s);
  115. -             nl();
  116. -             nl();
  117. -             pl(get_string(781));
  118. =             nl();
  119. =             outstr(get_string(782));
  120.  
  121. ══[ Step 7 ]══════════════════════════════════════════════════════════════════
  122.  
  123. Add the following in "int try_to_download".
  124.  
  125. =     if ((i1) || (strncmp(u.filename,"WWIV4",5)==0)) {
  126. =       sprintf(s1,"%s%s",directories[dn].path,u.filename);
  127. =       sent=0;
  128. =       abort=0;
  129. +       _chmod(dszlog,1,0);
  130. +       unlink(dszlog);
  131. =       if (i1==-1)
  132. =         send_file(s1,&sent,&abort,u.filetype,u.filename,dn, -2L);
  133. =       else
  134. =         send_file(s1,&sent,&abort,u.filetype,u.filename,dn, u.numbytes);
  135.  
  136. ══[ Step 8 ]══════════════════════════════════════════════════════════════════
  137.  
  138. Still in "int try_to_download", make the changes indicated.
  139.  
  140. =         thisuser.dk += (int) ((u.numbytes+1023)/1024);
  141. =         ++u.numdloads;
  142. =         SETREC(i);
  143. =         write(dlf,(void *)&u,sizeof(uploadsrec));
  144. +         nl();
  145. +         process_cps(u.filename,"");
  146. -         sprintf(s1,get_stringx(1,43),u.filename);
  147. -         sysoplog(s1);
  148. -         nl();
  149. =         nl();
  150. =         outstr(get_string(782)); npr("%-6.3f\r\n", ratio());
  151.  
  152. ══[ Step 9 ]══════════════════════════════════════════════════════════════════
  153.  
  154. In XFEROVL.C, add the following two functions to the end of the file.
  155.  
  156. void handle_cps(char *l, char *s, char *s1)
  157. {
  158.   char *ss;
  159.   int i;
  160.   long cps;
  161.   char s2[81];
  162.  
  163.   /* find the filename */
  164.   ss=strtok(l," \t");
  165.   for (i=0; (i<5) && (ss); i++) {
  166.     switch(i) {
  167.       case 4: cps=atol(ss); break;
  168.     }
  169.     ss=strtok(NULL," \t");
  170.   }
  171.  
  172.   if (ss) {
  173.  
  174.     switch(*l) {
  175.       case 'Z':
  176.       case 'r':
  177.       case 'R':
  178.       case 'B':
  179.       case 'H':
  180.     /* received a file */
  181.     sprintf(s2,get_stringx(1,54),s,s1,cps);
  182.     sysoplog(s2);
  183.     sprintf(s2,"Uploaded '%s' (%ld cps)",s,cps);
  184.     nl();
  185.     pl(s2);
  186.     break;
  187.  
  188.       case 'z':
  189.       case 's':
  190.       case 'S':
  191.       case 'b':
  192.       case 'h':
  193.     /* sent a file */
  194.     sprintf(s2,get_stringx(1,50),s,cps);
  195.     sysoplog(s2);
  196.         nl();
  197.     pl(s2);
  198.     break;
  199.  
  200.       case 'E':
  201.       case 'e':
  202.       case 'L':
  203.       case 'l':
  204.       case 'U':
  205.         /* error */
  206.     sprintf(s2,get_stringx(1,60),s);
  207.     sysoplog(s2);
  208.     break;
  209.     }
  210.   }
  211. }
  212.  
  213. void process_cps(char *s, char *s1)
  214. {
  215.   int f,i,i1;
  216.   char *ss,*line;
  217.  
  218.   f=open(dszlog,O_RDONLY | O_TEXT);
  219.   if (f>0) {
  220.     i1=(int)filelength(f);
  221.     ss=malloca(i1);
  222.     if (ss) {
  223.       i=read(f,ss,i1);
  224.       if (i>0) {
  225.         ss[i]=0;
  226.         line=strtok(ss,"\n");
  227.         handle_cps(line,s,s1);
  228.       }
  229.       farfree(ss);
  230.     }
  231.     close(f);
  232.   }
  233. }
  234.  
  235. ══[ Step 10 ]═════════════════════════════════════════════════════════════════
  236.  
  237. In FCNS.H, add the following two lines.
  238.  
  239. = void upload_files(char *fn, int dn, int type);
  240. = int uploadall(int dn);
  241. + void handle_cps(char *l, char *s, char *s1);
  242. + void process_cps(char *s, char *s1);
  243. =
  244. =
  245. = /* File: xfertmp.c */
  246.  
  247. ══[ Step 11 ]═════════════════════════════════════════════════════════════════
  248.  
  249. Compile your source.
  250.  
  251. ══[ Disclaimer ]══════════════════════════════════════════════════════════════
  252.  
  253. Don't complain to me if your board gets fried, your hard disk goes nuts, or
  254. something terrible happens.  The code in this mod should be harmless, but I
  255. can't guarantee it will work for you.  It works on my board.
  256.  
  257. JAFO 1@1     TerraNET
  258.      1@8857  IceNET
  259.      1@8861  WWIVnet
  260.      1@18857 WWIVLink
  261. 9
  262. 9          7───────────────────── 1Blue Thunder BBS 7─────────────────────
  263. 8          1TerraNET @1 7∙ 1IceNET @8857 7∙ 1WWIVnet @8861 7∙ 1WWIVLink @188680
  264.